package com.cch.demo.sys.controller;

import java.util.List;

import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cch.demo.sys.domain.AdataSource;
import com.cch.demo.sys.service.impl.AdataSourceServiceImpl;
import com.cch.demo.sys.util.DataGridView;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 华哥
 * @since 2020-03-11
 */
@RestController
@RequestMapping("/dataSource")
public class AdataSourceController {

    @Resource
    private AdataSourceServiceImpl aDataSourceServiceImpl;

    @RequestMapping("/loadAllDataSource")
    public DataGridView loadAllGoods(){
        QueryWrapper<AdataSource> queryWrapper = new QueryWrapper<>();

        IPage<AdataSource> page = new Page<>(1,10);
        aDataSourceServiceImpl.page(page,null);

        //给goods中供应商添加名字
        List<AdataSource> adataSources  = page.getRecords();
        return new DataGridView(page.getTotal(),adataSources);
    }
    
    @RequestMapping("/addDataSource")
    public boolean addDataSource(AdataSource adataSource){
    	boolean addDataSourceOnline = aDataSourceServiceImpl.addDataSourceOnline(adataSource);
    	return addDataSourceOnline;
    }
    

}

